package com.heima.mapper;

import com.github.pagehelper.Page;
import com.heima.pojo.Business;
import com.heima.pojo.Node;
import com.heima.pojo.dto.PageNodeDto;
import com.heima.pojo.vo.NodeInfoVo;
import com.heima.pojo.vo.NodeVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NodeMapper {
    Page<NodeVo> findByName(PageNodeDto pageRegionDto);

    @Select("select * from tb_business")
    List<Business> getBusinessType();

    Integer insertNode(Node node);

    List<NodeInfoVo> getVmList(String nodeId);

    Integer updateNode(@Param("nodeId") String nodeId, Node node);

    @Select("select count(*) from tb_vending_machine where node_id = #{nodeId}")
    Integer countByNodeId(String nodeId);

    @Delete("delete from tb_node where id = #{nodeId}")
    int deleteNode(String nodeId);

    @Select("select * from tb_node where id = #{nodeId}")
    Node getNodeById(Long nodeId);

    @Select("select user_name from tb_user where id = #{createUserId}")
    String getCreateUserName(Integer createUserId);

    Integer queryNodeCount(Integer userId);

}